<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */

/**
 * @see \Magento\Authorizenet\Block\Directpost\Form
 */
?>
<?php
$_form = $this;
$_code = $_form->getMethodCode();
$_method = $_form->getMethod();
$_controller = $this->getRequest()->getControllerName();
$_orderUrl = $this->helper('Magento\Authorizenet\Helper\Data')->getPlaceOrderFrontUrl();
?>

<!-- IFRAME for request to Authorize.net -->
<iframe id="directpost-iframe" data-container="authorize-net-iframe" allowtransparency="true" frameborder="0"  name="iframeDirectPost" style="display:none;width:100%;background-color:transparent" src="<?php echo $this->getViewFileUrl('blank.html') ?>"></iframe>
<form class="form" id="co-directpost-form" action="#" method="post" data-mage-init='{"directpost":{"methodCode":"<?php echo $_code ?>", "controller":"<?php echo $_controller ?>", "orderSaveUrl":"<?php echo $_orderUrl ?>", "cgiUrl":"<?php echo $_method->getCgiUrl() ?>", "nativeAction":"<?php echo $this->getUrl('checkout/onepage/saveOrder', array('_secure' => $this->getRequest()->isSecure())) ?>"}, "validation":[]}'>
    <fieldset class="fieldset ccard <?php echo $_code ?>" id="payment_form_<?php echo $_code ?>">
        <legend class="legend"><span><?php echo __('Credit Card Information') ?></span></legend><br />
        <div class="field required type">
            <label for="<?php echo $_code ?>_cc_type" class="label"><span><?php echo __('Credit Card Type') ?></span></label>
            <div class="control">
                <select id="<?php echo $_code ?>_cc_type" data-container="cc-type" name="payment[cc_type]" data-validate='{required:true, "validate-cc-type-select":"#<?php echo $_code ?>_cc_number"}'>
                    <option value=""><?php echo __('--Please Select--')?></option>
                <?php $_ccType = $_form->getInfoData('cc_type') ?>
                <?php foreach ($_form->getCcAvailableTypes() as $_typeCode => $_typeName): ?>
                    <option value="<?php echo $_typeCode ?>"<?php if($_typeCode==$_ccType): ?> selected="selected"<?php endif ?>><?php echo $_typeName ?></option>
                <?php endforeach ?>
                </select>
            </div>
        </div>
        <div class="field required number">
            <label for="<?php echo $_code ?>_cc_number" class="label"><span><?php echo __('Credit Card Number') ?></span></label>
            <div class="control">
                <input type="number" id="<?php echo $_code ?>_cc_number" data-container="cc-number" name="payment[cc_number]" title="<?php echo __('Credit Card Number') ?>" class="input-text" value="" data-validate='{required:true, "validate-cc-number":"#<?php echo $_code ?>_cc_type", "validate-cc-type":"#<?php echo $_code ?>_cc_type"}' autocomplete="off"/>
            </div>
        </div>
        <div class="field required date" id="<?php echo $_code ?>_cc_type_exp_div">
            <label for="<?php echo $_code ?>_expiration" class="label"><span><?php echo __('Expiration Date') ?></span></label>
            <div class="control">
                <div class="fields group group-2">
                    <div class="field no-label month">
                        <div class="control">
                            <select id="<?php echo $_code ?>_expiration" name="payment[cc_exp_month]" data-container="cc-month" class="month" data-validate='{required:true, "validate-cc-exp":"#<?php echo $_code ?>_expiration_yr"}'>
                            <?php $_ccExpMonth = $_form->getInfoData('cc_exp_month') ?>
                            <?php foreach ($_form->getCcMonths() as $k=>$v): ?>
                                <option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccExpMonth): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
                            <?php endforeach ?>
                            </select>
                        </div>
                    </div>
                    <div class="field no-label year">
                        <div class="control">
                            <?php $_ccExpYear = $_form->getInfoData('cc_exp_year') ?>
                            <select id="<?php echo $_code ?>_expiration_yr" name="payment[cc_exp_year]" class="year" data-container="cc-year" data-validate='{required:true}'>
                            <?php foreach ($_form->getCcYears() as $k=>$v): ?>
                                <option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccExpYear): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
                            <?php endforeach ?>
                            </select>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <?php if($_form->hasVerification()): ?>
        <div class="field required cvv" id="<?php echo $_code ?>_cc_type_cvv_div">
            <label for="<?php echo $_code ?>_cc_cid" class="label"><span><?php echo __('Card Verification Number') ?></span></label>
            <div class="control">
                <input type="number" title="<?php echo __('Card Verification Number') ?>" data-container="cc-cvv" class="input-text cvv" id="<?php echo $_code ?>_cc_cid" name="payment[cc_cid]" value="" data-validate='{required:true, "validate-cc-cvn":"#<?php echo $_code ?>_cc_type"}' autocomplete="off"/>
                <?php $_content = '<img src=\"'.$this->getViewFileUrl('Magento_Checkout::cvv.gif').'\" alt=\"'.__('Card Verification Number Visual Reference').'\" title=\"'.__('Card Verification Number Visual Reference').'\" />'; ?>
                <div class="note">
                    <a href="#" id="directpost-cvv-what-is-this" class="action cvv" title="<?php echo $this->escapeHtml(__('What is this?'));?>" data-mage-init='{"tooltip": {"content": "<?php echo $_content ?>"}}'><span><?php echo __('What is this?') ?></span></a>
                </div>
            </div>
        </div>
        <?php endif; ?>
    <?php echo $_form->getChildHtml() ?>
</fieldset>
</form>
